/*
 * @Author: 李超越 1509572300@qq.com
 * @Date: 2024-08-31 11:52:56
 * @LastEditors: 李超越 1509572300@qq.com
 * @LastEditTime: 2024-09-11 21:12:17
 * @FilePath: /my_git/lesson31_thread_Pool/LockGrand.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once
#ifndef __LOCK_GUARD_HPP__
#define __LOCK_GUARD_HPP__

#include <iostream>
#include <pthread.h>

class LockGuard
{
public:

    LockGuard(pthread_mutex_t *mutex):_mutex(mutex)
    {
        pthread_mutex_lock(_mutex); // 构造加锁
    }

    ~LockGuard()
    {
        pthread_mutex_unlock(_mutex);
    }
private:
    pthread_mutex_t *_mutex;
};

#endif
